var _class, _temp;

import Taro from '@tarojs/taro-rn';
import * as tslib_1 from "tslib";
import React from 'react';
import { Component } from "@tarojs/taro-rn";
import { observer, inject } from "@tarojs/mobx-rn";
import { Form, View, Textarea, Input, Button, Picker, Image } from "@tarojs/components-rn";
import { educationArr, getRuntime, userSexArr, workYearsArr, typeOfJobArr, monthlyPayArr, qualificationArr, registrationArr, servicePhoneNumber } from "../../utils/common";
import PageFooterInfo from "../../components/PageFooterInfo";
import rresumeStyleSheet from "./rresume_styles";
import right from "../../assets/img/right.png";
import { toJS } from "mobx";
var _styleSheet = rresumeStyleSheet;
let Rresume = (_temp = _class = class Rresume extends Component {
  constructor() {
    super(...arguments);

    this.changeArea = e => {
      let { allProvince } = this.state;
      let index = e.detail.value;
      this.setState({
        intentionArea: allProvince[index]['label'],
        intentionAreaCode: allProvince[index]['value']
      });
    };

    this.state = {
      publicationType: '4',
      // 基本新
      positionName: '',
      name: '',
      userSexArr: userSexArr,
      userSex: userSexArr[0],
      userSexId: 1,
      userBirth: '',
      educationArr: educationArr,
      education: educationArr[0],
      graduationSchool: '',
      professionalName: '',
      technicalTitleArr: [],
      technicalTitle: '',
      technicalTitleId: 0,
      workYearsArr: workYearsArr,
      workYears: workYearsArr[0],
      // 求职信息
      typeOfJobArr: typeOfJobArr,
      typeOfJob: typeOfJobArr[0],
      typeOfJobId: 1,
      positionOfJob: '',
      intentionArea: '',
      intentionAreaCode: '',
      monthlyPayArr: monthlyPayArr,
      monthlyPay: monthlyPayArr[0],
      // 职业信息
      qualificationArr: qualificationArr,
      qualification: '',
      registrationArr: registrationArr,
      registration: '',
      practiceTime: '',
      majorCategoryArr: '',
      majorCategory: '',
      majorCategoryId: 0,
      practiceExplain: '',
      description: '',
      // 最近工作经历
      businessName: '',
      jobPosition: '',
      startDateTime: '',
      endDateTime: '',
      experienceExplain: '',
      // 联系方式
      phone: '',
      wechatNo: '',
      qqNo: '',
      address: '',
      allProvince: [],
      provinceId: 0,
      loading: false,
      disabled: false,
      submitText: '立即发布',
      allProvince: []
    };
  }
  componentWillMount() {
    Taro.setNavigationBarTitle({ title: '发布简历' });
    this.getAllProvince();
    this.getAllTechnicalTitle();
    this.getAllMajorCategory();
  }
  getAllTechnicalTitle() {
    let { TalentStore } = this.props.stores;
    TalentStore.getAllTechnicalTitle({
      callback: res => {
        let resArr = toJS(res);
        console.log(resArr);
        this.setState({
          technicalTitleArr: res.items || [],
          technicalTitle: res.items[0]['titleName'] || '',
          technicalTitleId: res.items[0]['id'] || ''
        });
      }
    });
  }
  // 获取专业分类
  getAllMajorCategory() {
    let { TalentStore } = this.props.stores;
    TalentStore.getAllMajorCategory({
      callback: res => {
        let resArr = toJS(res);
        // console.log(resArr)
        this.setState({
          majorCategoryArr: res.items || [],
          majorCategory: res.items[0]['majorCateName'] || '',
          majorCategoryId: res.items[0]['id'] || ''
        });
      }
    });
  }
  getAllProvince() {
    let { AreaStore } = this.props.stores;
    AreaStore.getAllProvinceFromLocal({
      callBack: res => {
        this.setState({
          allProvince: res
        });
      }
    });
  }
  changePicker(type, e) {
    let index = e.detail.value;
    this.setState({
      [type]: this.state[type + 'Arr'][index]
    });
    if (type === 'typeOfJob') {
      this.setState({
        typeOfJobId: index
      });
    }
    if (type === 'userSex') {
      this.setState({
        userSexId: index
      });
    }
  }
  // 日期选择器
  changeDate(type, e) {
    this.setState({
      [type]: e.detail.value
    });
  }
  // 职称选择
  changeTechnical(e) {
    let index = e.detail.value || 0;
    let { technicalTitleArr: t } = this.state;
    this.setState({
      technicalTitle: t[index]['titleName'],
      technicalTitleId: t[index]['id']
    });
  }
  // 专业类别选择
  changeMajorCategory(e) {
    let index = e.detail.value || 0;
    let { majorCategoryArr: t } = this.state;
    this.setState({
      majorCategory: t[index]['majorCateName'],
      majorCategoryId: t[index]['id']
    });
  }
  formSubmit(e) {
    const { homeStore } = this.props.stores;
    let { publicationType, userSexId, education, workYears, typeOfJobId, monthlyPay, registration, userBirth, intentionAreaCode, practiceTime, startDateTime, endDateTime, technicalTitleId, majorCategoryId } = this.state;
    let { positionName, name, graduationSchool, professionalName, positionOfJob, qualification, practiceExplain, description, businessName, jobPosition, experienceExplain, phone, wechatNo, qqNo, address } = e.detail.value;
    if (!positionName) {
      getRuntime().showToast('求职标题不能为空~');
      return;
    }
    if (!name) {
      getRuntime().showToast('姓名不能为空~');
      return;
    }
    if (!education) {
      getRuntime().showToast('学历不能为空~');
      return;
    }
    if (!phone) {
      getRuntime().showToast('联系电话不能为空~');
      return;
    }
    this.setState({
      loading: true,
      disabled: true,
      submitText: '数据提交中...'
    });
    homeStore.saveUserInfomations({
      form: {
        publicationType,
        positionName,
        name,
        userSex: userSexId + 1,
        userBirth,
        education,
        graduationSchool,
        professionalName,
        technicalTitleId,
        workYears,
        typeOfJob: typeOfJobId + 1,
        positionOfJob,
        intentionAreaCode,
        monthlyPay,
        qualification,
        registration,
        practiceTime,
        majorCategoryId,
        practiceExplain,
        description,
        businessName,
        jobPosition,
        startDateTime,
        endDateTime,
        experienceExplain,
        phone,
        wechatNo,
        qqNo,
        address
      },
      callBack: () => {
        this.setState({
          loading: false,
          disabled: false,
          submitText: '立即发布'
        });
        getRuntime().showToast('数据提交成功~');
        setTimeout(() => {
          getRuntime().navigateTo('/pages/newest/index');
        }, 2000);
      }
    });
  }
  render() {
    let { allProvince, intentionArea, userSexArr, educationArr, workYearsArr, typeOfJobArr, monthlyPayArr, registrationArr, technicalTitleArr, userSex, education, workYears, typeOfJob, monthlyPay, majorCategoryArr, majorCategory, registration, technicalTitle, userBirth, practiceTime, startDateTime, endDateTime, loading, disabled, submitText } = this.state;
    return <View style={_styleSheet["from-wrap"]}>
        <Form onSubmit={this.formSubmit.bind(this)}>
          <View style={_styleSheet["item-group-title"]}>－ 基本信息 －</View>
          <View style={[_styleSheet["item-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
            <View style={_styleSheet["input-group"]}>
              <View style={[_styleSheet["input-name"], _styleSheet["is-require"]]}>求职标题</View>
              <Input placeholder="请填写招求职标题(例：一级建造师)" placeholderClass="placeholder_class" name="positionName" style={_styleSheet["from-input"]} />
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={[_styleSheet["input-name"], _styleSheet["is-require"]]}>姓名</View>
              <Input placeholderClass="placeholder_class" placeholder="请输入您的姓名" name="name" style={_styleSheet["from-input"]} />
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>性别</View>
              <Picker mode="selector" name="userSex" range={userSexArr} onChange={this.changePicker.bind(this, 'userSex')} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{userSex}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>出生年月</View>
              <Picker mode="date" name="userBirth" range={this.state.selector} onChange={this.changeDate.bind(this, 'userBirth')} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{userBirth}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>

            <View style={[_styleSheet["input-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
              <View style={_styleSheet["input-name"]}>学历</View>
              <Picker mode="selector" name="education" range={educationArr} onChange={this.changePicker.bind(this, 'education')} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{education}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>

            <View style={[_styleSheet["input-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
              <View style={_styleSheet["input-name"]}>毕业院校</View>
             
              <Input placeholder="请填写毕业院校" placeholderClass="placeholder_class" name="graduationSchool" style={_styleSheet["from-input"]} />
            </View>

            <View style={[_styleSheet["input-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
              <View style={_styleSheet["input-name"]}>专业名称</View>
             
              <Input placeholder="请填写专业名称" placeholderClass="placeholder_class" name="professionalName" style={_styleSheet["from-input"]} />
            </View>

            <View style={[_styleSheet["input-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
              <View style={_styleSheet["input-name"]}>职称</View>
              <Picker mode="multiSelector" name="technicalTitle" range={[technicalTitleArr]} rangeKey={'titleName'} onChange={this.changeTechnical.bind(this)} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{technicalTitle}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>

            <View style={[_styleSheet["input-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
              <View style={_styleSheet["input-name"]}>工作年限</View>
              <Picker mode="selector" name="workYears" range={workYearsArr} onChange={this.changePicker.bind(this, 'workYears')} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{workYears}年</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>
          </View>

          <View style={_styleSheet["item-group-title"]}>－ 求职信息 －</View>
          <View style={[_styleSheet["item-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>求职类型</View>
              <Picker mode="selector" name="typeOfJob" range={typeOfJobArr} onChange={this.changePicker.bind(this, 'typeOfJob')} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{typeOfJob}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>求职职位</View>
             
              <Input placeholder="请填写求职职位" placeholderClass="placeholder_class" name="positionOfJob" style={_styleSheet["from-input"]} />
            </View>


            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>想在哪工作</View>
              <Picker mode="multiSelector" name="intentionArea" range={[allProvince]} rangeKey={'label'} onChange={this.changeArea.bind(this)} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{intentionArea}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>


            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>月薪</View>
              <Picker mode="selector" name="monthlyPay" range={monthlyPayArr} onChange={this.changePicker.bind(this, 'monthlyPay')} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{monthlyPay}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>
          </View>

          <View style={_styleSheet["item-group-title"]}>－ 执业信息 －</View>
          <View style={[_styleSheet["item-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>执业资格</View>
              
              <Input placeholder="请填写执业资格" placeholderClass="placeholder_class" name="qualification" style={_styleSheet["from-input"]} />
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>注册情况</View>
              <Picker mode="selector" name="registration" range={registrationArr} onChange={this.changePicker.bind(this, 'registration')} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{registration}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>执业时间</View>
              <Picker mode="date" name="practiceTime" range={this.state.selector} onChange={this.changeDate.bind(this, 'practiceTime')} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{practiceTime}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>专业类别</View>
              <Picker mode="multiSelector" name="majorCategoryId" range={[majorCategoryArr]} rangeKey={'majorCateName'} onChange={this.changeMajorCategory.bind(this)} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{majorCategory}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>

            <Textarea placeholderClass="placeholder-class" placeholder="请填写执业资格信息(选填)" maxlength={-1} name="practiceExplain" style={[_styleSheet["from-textarea"], _styleSheet["height100"]]} />

          </View>


          <View style={_styleSheet["item-group-title"]}>－ 转会要求 －</View>
          <View style={[_styleSheet["input-group"], _styleSheet["pt0"], _styleSheet["pb0"], { 'margin-bottom': '10px' }]}>
            <Textarea placeholderClass="placeholder-class" placeholder="请填写转会要求(选填)" maxlength={-1} name="description" style={_styleSheet["from-textarea"]} />
          </View>

          <View style={_styleSheet["item-group-title"]}>－ 最近工作经历 －</View>
          <View style={[_styleSheet["item-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>企业名称</View>
              <Input placeholder="请填写联系人姓名" placeholderClass="placeholder_class" name="businessName" style={_styleSheet["from-input"]} />
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>工作职位</View>
              <Input placeholderClass="placeholder_class" placeholder="请填写工作职位" name="jobPosition" style={_styleSheet["from-input"]} />
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>开始时间</View>
              <Picker mode="date" name="startDateTime" range={this.state.selector} onChange={this.changeDate.bind(this, 'startDateTime')} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{startDateTime}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>结束时间</View>
              <Picker mode="date" name="endDateTime" range={this.state.selector} onChange={this.changeDate.bind(this, 'endDateTime')} style={_styleSheet["input-picker"]}>
                <View style={_styleSheet["tt"]}>
                  <View style={[_styleSheet["from-input"], _styleSheet["picker-con"]]}>{endDateTime}</View>
                  <Image src={right} style={_styleSheet["drop-down-icon"]} />
                </View>
              </Picker>
            </View>


            <Textarea placeholderClass="placeholder-class" placeholder="请输入职位描述" maxlength={-1} name="experienceExplain" style={[_styleSheet["from-textarea"], _styleSheet["height100"]]} />

          </View>

          <View style={_styleSheet["item-group-title"]}>－ 联系方式 －</View>
          <View style={[_styleSheet["item-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>联系人</View>
              <Input placeholder="请填写联系人姓名" placeholderClass="placeholder_class" name="contacts" style={_styleSheet["from-input"]} />
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>联系电话</View>
              <Input type={"number"} maxLength={11} placeholderClass="placeholder_class" placeholder="请填写联系电话" name="phone" style={_styleSheet["from-input"]} />
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>微信号</View>
              <Input placeholderClass="placeholder_class" placeholder="请填写微信号" name="wechatNo" style={_styleSheet["from-input"]} />
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>QQ号</View>
              <Input type={"number"} placeholderClass="placeholder_class" placeholder="请填写QQ号" name="qqNo" style={_styleSheet["from-input"]} />
            </View>

            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>联系地址</View>
              <Input placeholderClass="placeholder_class" placeholder="请填写联系地址" name="address" style={_styleSheet["from-input"]} />
            </View>
          </View>

          <Button type="primary" formType="submit" loading={loading} disabled={disabled} style={_styleSheet["from-submit"]}>{submitText}</Button>

          <PageFooterInfo info={'咨询热线：' + servicePhoneNumber} />
        </Form>
      </View>;
  }
}, _class.config = {
  navigationBarTitleText: '发布简历'
}, _temp);
Rresume = tslib_1.__decorate([inject("stores"), observer], Rresume);
export default Rresume;